package com.biz.primus.app.rest.handler.impl;

import com.biz.primus.app.rest.handler.BuildRequestHandler;
import com.biz.primus.base.exception.BizBusinessException;
import com.biz.primus.base.vo.handler.IRequestVo;
import com.biz.primus.base.vo.handler.PostInitializationAware;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * 后置初始化处理器,如果请求对象实现了PostInitialization接口,调用该对象的postInitializing()方法
 *
 * @author jun.liu
 * @usage
 * @reviewer
 * @since 2017年11月3日
 */
@Component
@Slf4j
public class PostInitializationHandler implements BuildRequestHandler
{

    @Override
    public void handle(HttpServletRequest request, IRequestVo requestVo) throws BizBusinessException
    {
        if (requestVo instanceof PostInitializationAware)
        {
            ((PostInitializationAware) requestVo).postInitializing();
        }
    }

    @Override
    public int getOrder() {
        return BuildRequestHandler.PostInitializationHandlerOrderVaule;
    }

}
